package com.thiscc.sum.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mongodb.DBObject;
import com.thiscc.sum.logic.ShareLogic;
import com.thiscc.sum.utils.ResponseUtils;

/**
 * 总结的分享操作
 * @author DK
 * @createTime 2014.12.15
 * @version 1.0
 */
@Controller
@RequestMapping("share")
public class ShareController {

    @Autowired
    private ShareLogic shareLogic;

    /*-------------------------------------------------------------------------------------------*/

    /**
     * 获得某条总结所有的被分享数据
     * @param request
     *              perPageCount 每页显示的条数
     *              pageNo   第几页
     *              ccno     被分享人的ccno
     *              _id      该总结数据的编号
     * @param response
     * @author DK
     */
    @RequestMapping("getShareDate")
    public void getShareDate(HttpServletRequest request, HttpServletResponse response) {

        String result = shareLogic.getShare(request);
        ResponseUtils.send(response, result);
    }

    /*-------------------------------------------------------------------------------*/
    /**
     * 分享总结，分享某一个人的总结给其他人或部门
     * @param request
     *        shareData  被分享的数据数组
     *        companyno  公司编号
     *        s_uuidData 被选定的uuid数组
     *        groupidData 被选定的部门的id数组
     * @param response
     * @author DK
     * @createTime 2014-12-15
     */
    @RequestMapping("shareMarize")
    public void shareMarize(HttpServletRequest request, HttpServletResponse response) {

        String result = shareLogic.shareMarize(request);
        ResponseUtils.send(response, result);
    }

    /*-------------------------------------------------------------------------------------------*/
    /**
     *	分享我的条数
     * @param uuid 用户uuid
     * @param ccno 用户ccno
     *	分享页面---分享我的条数
     * @param uuid //用户uuid
     * @author 易泉 2014-12-15 16:14:00 
     */
    @RequestMapping("shareCount")
    public void shareCount(HttpServletRequest request, HttpServletResponse response) {

        String s_ret = shareLogic.shareCount(request);
        ResponseUtils.send(response, s_ret);
    }

    /*-------------------------------------------------------------------------------------------*/
    /**
     *	分享页面的分享我查询
     * @param ccno:用户ccno
     * @param pageNo:当前页数
     * @param perPageCount:总页数
     * @author 易泉
     */
    @RequestMapping("shareMe")
    public void shareMe(HttpServletRequest request, HttpServletResponse response) {

        String s_result = shareLogic.shareMe(request);
        ResponseUtils.send(response, s_result);
    }

    /*-------------------------------------------------------------------------------------------*/
    /**
     *	分享页面的我分享查询
     * @param uuid:用户uuid
     * @param pageNo:当前页数
     * @param perPageCount:总页数
     * @author 易泉
     */
    @RequestMapping("meShare")
    public void meShare(HttpServletRequest request, HttpServletResponse response) {

        String s_result = shareLogic.meShare(request);

        ResponseUtils.send(response, s_result);
    }

    /*-------------------------------------------------------------------------------------------*/
    /**
     *	分享操作成功进入的接口
     * @param uuid //选中的多个人
     * @param companyno 公司编号
     * @param frameuuid 部门uuid
     * @param functionid=110519816015296 分享我的功能ID
     * @author 易泉 
     */
    @RequestMapping("shareSuccess")
    public void shareSuccess(HttpServletRequest request, HttpServletResponse response) {

        String s_result = shareLogic.shareSuccess(request, response);

        ResponseUtils.send(response, s_result);
    }

    /**
     * 查询共享
     * @author helios
     * @param request
     * @param response
     * @createtime 2015-1-13
     * @since 1.0
     */
    @RequestMapping("shareAll")
    public void shareAll(HttpServletRequest request, HttpServletResponse response) {

        List<DBObject> l_ret = shareLogic.shareToAll(request);

        ResponseUtils.send(response, l_ret.toString());
    }
}
